<template>
  <el-table :data="tableData">
<!--  prop=property属性  -->
    <el-table-column prop="date" label="日期"></el-table-column>
    <el-table-column prop="name" label="名字"></el-table-column>
    <el-table-column prop="address" label="地址"></el-table-column>
  </el-table>
  <h3>员工列表</h3>
  <el-table :data="arr">
    <el-table-column type="index" label="编号" width="60px"></el-table-column>
    <el-table-column prop="name" label="名字"></el-table-column>
    <el-table-column prop="salary" label="工资"></el-table-column>
    <el-table-column prop="job" label="工作"></el-table-column>
    <el-table-column label="操作">
      <template #default="scope">
        <el-button type="danger" @click="del(scope.$index,scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <h3>新的员工列表</h3>
  <el-table :data="arr">
    <el-table-column v-for="item in tableColumns"
                     v-bind="item"></el-table-column>
  </el-table>
</template>
<script setup>
import {ref} from "vue";
const tableColumns = ref([
    {type:'index',width:80,label:'编号'},
    {prop:'name',label:'姓名'},
    {prop:'salary',label:'工资'},
    {prop:'job',label:'工作'},
])
const del = (i,emp)=>{
  if (confirm("您确认删除"+emp.name+"吗?")){
    arr.value.splice(i,1);
  }
}
const arr = ref([{name:"张三",salary:3000,job:"销售"},
  {name:"李四",salary:4000,job:"人事"},
  {name:"王五",salary:5000,job:"程序员"}]);

const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
</script>

<style scoped>

</style>